package hn.cch.kafka.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.listener.BatchAcknowledgingMessageListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class BatchListener implements BatchAcknowledgingMessageListener<String, String> {

    private final static Logger logger = LoggerFactory.getLogger(BatchListener.class);

    @Override
    public void onMessage(List<ConsumerRecord<String, String>> list, Acknowledgment acknowledgment) {
        logger.info("batch size:{}", list.size());
        try {
            Thread.sleep(10 * 1000L);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        // acknowledgment.acknowledge();
    }
}
